//
//  PAHeadPicView.m
//  PAMobileWallet
//
//  Created by Pay_SMP002 on 13-7-3.
//  Copyright (c) 2013年 平安付. All rights reserved.
//

#import "PAHeadPicView.h"
#import "PAHeadPicViewController.h"
#import "PAAsynImageView.h"

@implementation PAHeadPicView
@synthesize mobileButton;
@synthesize photoButton;
@synthesize photoImageView;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        CGFloat x, y, w, h;
        CGSize size = frame.size;

        w = 578/2;
        h = 98/2;
        x = (size.width - w) / 2;
        y = 575/2;

        mobileButton = [UIButton buttonWithType:UIButtonTypeCustom];
        mobileButton.frame = CGRectMake(x, y, w, h);
        mobileButton.backgroundColor = [UIColor clearColor];
        [mobileButton setTitle:@"下一步" forState:UIControlStateNormal];
        [mobileButton setBackgroundImage:[UIImage imageNamed:@"button_B1.png"] forState:UIControlStateNormal];
        mobileButton.titleLabel.textColor = ENABLE_COLOR;
        mobileButton.titleLabel.font = [UIFont systemFontOfSize:18.0];
        [mobileButton addTarget:self action:@selector(buttonActive:) forControlEvents:UIControlEventTouchUpInside];
        mobileButton.tag = 0;
        [self addSubview:mobileButton];

        CGSize buttonSize = CGSizeMake(211, 211);
        
        photoImageView = [[PACircleHeadImage alloc] initWithFrame:CGRectMake((size.width - buttonSize.width)/2, 121/2, buttonSize.width, buttonSize.height)];
        [photoImageView setHeadImage:[UIImage imageNamed:@"register_takepic.png"]];
        photoImageView.backgroundColor = [UIColor clearColor];
        [self addSubview:photoImageView];
        
        photoButton = [UIButton buttonWithType:UIButtonTypeCustom];
        photoButton.backgroundColor = [UIColor clearColor];
        photoButton.frame = CGRectMake((size.width - buttonSize.width)/2, 121/2, buttonSize.width, buttonSize.height);
        photoButton.tag = 1;
        [photoButton addTarget:self action:@selector(buttonActive:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:photoButton];

        UIImageView * lableBgImage = [[UIImageView alloc] initWithFrame:CGRectMake(x, y+h+5, w, 100)];
        lableBgImage.image = [UIImage imageNamed:@"register_textbox.png"];
        [self addSubview:lableBgImage];
        
        UILabel * markLable = [[UILabel alloc] initWithFrame:CGRectMake(x+5, y+h+5+20, w-10, 60)];
        markLable.text = @"您的头像将成为对方识别的依据,请确保头像清晰,可识别.";
        markLable.numberOfLines = 2;
        markLable.backgroundColor = [UIColor clearColor];
        [markLable setFont:[UIFont systemFontOfSize:18.0]];
        [self addSubview:markLable];
        
        [self setShowMode:0];
    }
    return self;
}

- (IBAction)buttonActive:(id)sender
{
    [self.parentController testNext:sender];
}

- (void)setShowMode:(int)mode
{
    nMode = mode;
    if (nMode == HEADPICMODE_change)
    {
        mobileButton.hidden = YES;
    }
    else
    {
        mobileButton.hidden = NO;
    }
}


@end
